<?php require_once VIEWPATH . 'common/header.php'; ?>
<link href="<?= STATICURL; ?>luckydog/css/timeline.css" rel="stylesheet" type="text/css"/>
<div class="wrapper wrapper-content animated fadeInRight">
    <?php if(date("Y",strtotime($recordList[0]['deliver_time']))==0):?>
    <div class="Huialert Huialert-danger text-c"><i class="Hui-iconfont"></i>待发货</div>
    <?php endif;?>
    <div class="row pd-30">
        <div class="col-sm-12">
            <div class="ibox-content p-xl">
                <div class="row col-sm-3">
                        <strong>单据编号：</strong>
                        <h4 class="text-navy c-green"><?=$recordList[0]['contract_number']?></h4>
                        <p>
                            <span><strong>下单日期：</strong> <?=$recordList[0]['signed_time']?>1</span>
                        </p>
                    <address class="btn btn-success radius" onClick="J_express_detail()" >
                        查看物流
                    </address>

                </div>
                <div class="row col-sm-3">
                    <strong>订单号：</strong>
                    <h4 class="text-navy c-green"><?=$recordList[0]['order_number']?></h4>

                </div>
                </div>
                <div class="row col-sm-6">
                        <address>
                            <strong>收件人信息：</strong><br> <?=$recordList[0]['contact']?><br>
                        </address>
                    <div class="history">
                        <div class="history-date">

                            <ul>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="table-responsive m-t">
                    <table class="table">
                        <thead >
                        <tr >
                            <th>清单</th>
                            <th>数量</th>
                            <th>采购单价</th>
                            <th>销售单价</th>
                            <th>利润</th>
                        </tr>
                        </thead>
                        <tbody class="table-border">
                        <?php foreach($recordList as $record):?>
                        <tr>
                            <td>
                                <div><strong><?=$record['name']?></strong>
                                </div>
                            </td>
                            <td><?=$record['number']?></td>
                            <td>¥<?=$record['purchase_price']?></td>
                            <td>¥<?=$record['unit_selling_price']?></td>
                            <td>¥<?=$record['number']*($record['unit_selling_price']-$record['purchase_price'])?></td>
                        </tr>
                        <?php endforeach;?>
                        </tbody>
                    </table>
                </div>
                <!-- /table-responsive -->
                <div class="well mt-20"><strong>注意：</strong><br />
                    <?php foreach($recordList as $record):?>
                            <div class="label label-warning radius"><?=$record['remark']?></div>
                    <?php endforeach;?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php require_once VIEWPATH . 'common/footer.php'; ?>
</body>
</html>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

    mustNum($("#purchase_price"));
    mustNum($("#unit_selling_price"));

    function mustNum($object){
        $object.bind({
                keyup:function(){
                     var txt = $object.val();
                     var reg = /^[\d]+$/;
                     if(!reg.test(txt) ){
                            $(this).val('');
                     }
                },
                focus:function(){
                    if ($(this).val() == 0){
                        $(this).val('');
                    }
                },
                blur:function(){
                    if ($(this).val() == ''){
                        $(this).val('');
                    }
                }
        }); 
    }

    function J_express_detail() {
        var order_number = "<?=$recordList[0]['order_number']?>";
        $.get("/express/searchExpress", {order_number:order_number}, function (data) {

            if (data.code != 1) {
                layer.msg(data.message);
                return false;
            }
            var _express_name_place = '<div class="mb-20"><b class="c-green">'+data.data.express_name+'</b></div>';
            $(".history-date").prepend(_express_name_place);
            var _li = '';
            var _font_color = '';
            $.each(data.data.express_data,function(index,val){
                _font_color = '';
                if(index == 0){
                    _font_color = 'green'
                }
                _li +=
                    '<li class="'+_font_color+'">' +
                    '<h3 style="padding-top:0">'+val.time+'<span>'+val.year+'</span></h3>' +
                    '<dl> ' +
                    '<dt><span>'+val.context+'</span></dt> ' +
                    '</dl> ' +
                    '</li>';
            });
            $(".history-date ul").html(_li);
            $.getScript("<?= STATICURL; ?>luckydog/js/timeline.js");
        },'json');
    }
</script>
